<?php

Yii::import('zii.widgets.CPortlet');

class NavigationBar extends CPortlet
{
    public $specialMenuItem;

	public $menuitemModel;
    
    public function init()
	{
        /**
         * show the navigation bar
         * @author : nonglei
         * @date   : 14/03/2014
         */
        $this->contentCssClass="navigationbar";
    	$cs = Yii::app()->getClientScript();
        $cs->registerCssFile(Yii::app()->baseUrl.'/css/navigationbar.css');
	//	$cs->registerScriptFile(Yii::app()->baseUrl.'/js/picturesnews.js');
        $this->menuitemModel = Menuitem::model()->findAll("status = 1");
        /**
         * check the menuitem have submenu or not
         * @author : nonglei
         * @date   : 08/05/2014
         */
        foreach($this->menuitemModel as $k=>$v)
        {
            $specialMenuItemExist = false;
            foreach($this->specialMenuItem as $elem)
            {
                if($elem['relegation'] == $v->menuitem_id)
                {
                    $specialMenuItemExist =true;
                    break;
                }
            }
            if(!$specialMenuItemExist && count($v->tblSubmenus) == 0)
            {
                unset($this->menuitemModel[$k]);
            }
        }
        parent::init();
	}
	protected function renderContent()
	{
		$this->render('navigationbar');
	}
}

?>
